import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 资产信息 */
export interface Asset {
          id: number; // 编号
          name?: string; // 资产名称
          assetTypeId?: number; // 资产编号
          properties: string; // 属性
          price: number; // 价格
          mac: string; // mac地址
          imgUrl: string; // 图片地址
  }

// 资产 API
export const AssetApi = {
  // 查询资产分页
  getAssetPage: async (params: any) => {
    return await request.get({ url: `/dorm/asset/page`, params })
  },

  // 查询资产详情
  getAsset: async (id: number) => {
    return await request.get({ url: `/dorm/asset/get?id=` + id })
  },

  // 新增资产
  createAsset: async (data: Asset) => {
    return await request.post({ url: `/dorm/asset/create`, data })
  },

  // 修改资产
  updateAsset: async (data: Asset) => {
    return await request.put({ url: `/dorm/asset/update`, data })
  },

  // 删除资产
  deleteAsset: async (id: number) => {
    return await request.delete({ url: `/dorm/asset/delete?id=` + id })
  },

  /** 批量删除资产 */
  deleteAssetList: async (ids: number[]) => {
    return await request.delete({ url: `/dorm/asset/delete-list?ids=${ids.join(',')}` })
  },

  // 导出资产 Excel
  exportAsset: async (params) => {
    return await request.download({ url: `/dorm/asset/export-excel`, params })
  },
}